package com.cssy.authority.dao.impl;

import com.cssy.authority.dao.LoginHistoryDAO;
import com.cssy.authority.entity.LoginHistory;
import com.cssy.authority.entity.LoginHistoryExample;
import com.ibatis.sqlmap.client.SqlMapClient;
import java.sql.SQLException;
import java.util.List;

public class LoginHistoryDAOImpl implements LoginHistoryDAO {
    private SqlMapClient sqlMapClient;

    public LoginHistoryDAOImpl(SqlMapClient sqlMapClient) {
        super();
        this.sqlMapClient = sqlMapClient;
    }

    public void insert(LoginHistory record) throws SQLException {
        sqlMapClient.insert("logic_login_history.abatorgenerated_insert", record);
    }

    public int updateByPrimaryKey(LoginHistory record) throws SQLException {
        int rows = sqlMapClient.update("logic_login_history.abatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    public int updateByPrimaryKeySelective(LoginHistory record) throws SQLException {
        int rows = sqlMapClient.update("logic_login_history.abatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    public List selectByExample(LoginHistoryExample example) throws SQLException {
        List list = sqlMapClient.queryForList("logic_login_history.abatorgenerated_selectByExample", example);
        return list;
    }

    public LoginHistory selectByPrimaryKey(Long id) throws SQLException {
        LoginHistory key = new LoginHistory();
        key.setId(id);
        LoginHistory record = (LoginHistory) sqlMapClient.queryForObject("logic_login_history.abatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    public int deleteByExample(LoginHistoryExample example) throws SQLException {
        int rows = sqlMapClient.delete("logic_login_history.abatorgenerated_deleteByExample", example);
        return rows;
    }

    public int deleteByPrimaryKey(Long id) throws SQLException {
        LoginHistory key = new LoginHistory();
        key.setId(id);
        int rows = sqlMapClient.delete("logic_login_history.abatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    public int countByExample(LoginHistoryExample example) throws SQLException {
        Integer count = (Integer)  sqlMapClient.queryForObject("logic_login_history.abatorgenerated_countByExample", example);
        return count.intValue();
    }

    public int updateByExampleSelective(LoginHistory record, LoginHistoryExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("logic_login_history.abatorgenerated_updateByExampleSelective", parms);
        return rows;
    }

    public int updateByExample(LoginHistory record, LoginHistoryExample example) throws SQLException {
        UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
        int rows = sqlMapClient.update("logic_login_history.abatorgenerated_updateByExample", parms);
        return rows;
    }

    private static class UpdateByExampleParms extends LoginHistoryExample {
        private Object record;

        public UpdateByExampleParms(Object record, LoginHistoryExample example) {
            super(example);
            this.record = record;
        }

        public Object getRecord() {
            return record;
        }
    }
}